package com.xxljob.demo.core.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @Author：YH
 * @Description：
 * @Date:Created in 2022/5/19 20:40
 */
public class XxlJobGroup {

    private int id;

    //执行器AppName
    private String appname;

    //执行器名称
    private String title;

    // 执行器地址类型：0=自动注册、1=手动录入
    private int addressType;

    // 执行器地址列表，多地址逗号分隔(手动录入)  http://192.168.56.1:9999/
    private String addressList;

    // registry list
    private List<String> registryList;  // 执行器地址列表(系统注册)

    //获取注册列表
    public List<String> getRegistryList() {
        if (Objects.nonNull(addressList) && addressList.trim().length() > 0) {
            registryList = new ArrayList<>(Arrays.asList(addressList.split(",")));
        }
        return registryList;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAppname() {
        return appname;
    }

    public void setAppname(String appname) {
        this.appname = appname;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getAddressType() {
        return addressType;
    }

    public void setAddressType(int addressType) {
        this.addressType = addressType;
    }

    public String getAddressList() {
        return addressList;
    }

    public void setAddressList(String addressList) {
        this.addressList = addressList;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("XxlJobGroup{");
        sb.append("id=").append(id);
        sb.append(", appname='").append(appname).append('\'');
        sb.append(", title='").append(title).append('\'');
        sb.append(", addressType=").append(addressType);
        sb.append(", addressList='").append(addressList).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
